﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.UpgradesUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.utils.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.geom.*;
    import flash.text.*;
    import Display.aswingui.*;

    public class UpgradesInfoBox extends JPanel {

        public static const BOX_WIDTH_PIC:Number = 300;
        public static const BOX_WIDTH_NO_PIC:Number = 200;
        public static const BOX_HEIGHT:Number = 175;

        protected var m_item:Item;
        protected var m_stats:Dictionary;
        protected var m_statsPanel:JPanel;
        protected var m_picture:DisplayObject;
        protected var m_pictureLoader:Loader;
        protected var m_picturePanel:JPanel;
        protected var m_bgAsset:DisplayObject;

        public function UpgradesInfoBox(_arg1:Object, _arg2:String){
            this.m_bgAsset = (new (_arg1)() as DisplayObject);
            this.m_item = Global.gameSettings.getItemByName(_arg2);
            this.m_stats = Global.gameSettings.getDisplayedStatsByName(_arg2);
            if (this.m_stats["picture"] != null){
                this.m_pictureLoader = LoadingManager.load(Global.getAssetURL(this.m_stats["picture"]), this.onPicLoad, LoadingManager.PRIORITY_HIGH);
            };
            super();
            this.setLayout(new SoftBoxLayout(SoftBoxLayout.X_AXIS, 0, SoftBoxLayout.TOP));
            this.buildCell();
        }
        protected function buildCell():void{
            this.m_statsPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.LEFT);
            this.buildBackground();
            if (this.m_stats["picture"] != null){
                this.m_picturePanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
                this.makePicturePanel();
            };
            this.makeStatsPanel();
            ASwingHelper.prepare(this);
        }
        protected function buildBackground():void{
            var _local1:MarginBackground;
            if (this.m_bgAsset){
                _local1 = new MarginBackground(this.m_bgAsset);
                this.setBackgroundDecorator(_local1);
                if (this.m_stats["picture"] != null){
                    this.setPreferredSize(new IntDimension(BOX_WIDTH_PIC, BOX_HEIGHT));
                    this.setMinimumSize(new IntDimension(BOX_WIDTH_PIC, BOX_HEIGHT));
                    this.setMaximumSize(new IntDimension(BOX_WIDTH_PIC, BOX_HEIGHT));
                } else {
                    this.setPreferredSize(new IntDimension(BOX_WIDTH_NO_PIC, BOX_HEIGHT));
                    this.setMinimumSize(new IntDimension(BOX_WIDTH_NO_PIC, BOX_HEIGHT));
                    this.setMaximumSize(new IntDimension(BOX_WIDTH_NO_PIC, BOX_HEIGHT));
                };
            };
        }
        protected function makePicturePanel():void{
            this.m_picturePanel.setPreferredWidth((BOX_WIDTH_PIC - BOX_WIDTH_NO_PIC));
            this.m_picturePanel.setMinimumWidth((BOX_WIDTH_PIC - BOX_WIDTH_NO_PIC));
            this.m_picturePanel.setMaximumWidth((BOX_WIDTH_PIC - BOX_WIDTH_NO_PIC));
            this.appendAll(ASwingHelper.horizontalStrut(10), this.m_picturePanel);
        }
        protected function makeStatsPanel():void{
            var _local3:JLabel;
            var _local4:JPanel;
            var _local5:DisplayObject;
            var _local6:JLabel;
            var _local7:JPanel;
            var _local8:DisplayObject;
            var _local9:JLabel;
            var _local10:JPanel;
            var _local11:DisplayObject;
            var _local12:JLabel;
            var _local13:JPanel;
            var _local14:DisplayObject;
            var _local15:JLabel;
            var _local16:JPanel;
            var _local17:DisplayObject;
            var _local18:JLabel;
            var _local19:JPanel;
            var _local20:JLabel;
            var _local21:JPanel;
            var _local22:DisplayObject;
            var _local23:JLabel;
            var _local24:JPanel;
            var _local25:JLabel;
            var _local26:JPanel;
            var _local27:String;
            var _local28:AssetPane;
            var _local1:ASColor = new ASColor(EmbeddedArt.blueTextColor);
            var _local2:ASColor = new ASColor(EmbeddedArt.greenTextColor);
            this.m_statsPanel.append(ASwingHelper.verticalStrut(10));
            if (((((((((this.m_stats["coin"]) || (this.m_stats["xp"]))) || (this.m_stats["goods"]))) || (this.m_stats["premium_goods"]))) || (this.m_stats["energy"]))){
                _local3 = new JLabel(ZLoc.t("Dialogs", "TT_Earnings"));
                _local3.setFont(ASwingHelper.getBoldFont(11));
                _local3.setForeground(_local1);
                _local4 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                _local4.append(_local3);
                this.m_statsPanel.append(_local4);
                if (this.m_stats["coin"]){
                    _local5 = (new EmbeddedArt.mkt_coinIcon() as DisplayObject);
                    _local6 = new JLabel(ZLoc.t("Dialogs", "NumCoins", {num:this.m_stats["coin"]}));
                    _local6.setFont(ASwingHelper.getBoldFont(12));
                    _local6.setForeground(_local2);
                    _local7 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local7.appendAll(new AssetPane(_local5), ASwingHelper.horizontalStrut(5), _local6);
                    this.m_statsPanel.append(_local7);
                };
                if (this.m_stats["xp"]){
                    _local8 = (new EmbeddedArt.mkt_xpIcon() as DisplayObject);
                    _local9 = new JLabel(ZLoc.t("Dialogs", "NumXP", {num:this.m_stats["xp"]}));
                    _local9.setFont(ASwingHelper.getBoldFont(12));
                    _local9.setForeground(_local2);
                    _local10 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local10.appendAll(new AssetPane(_local8), ASwingHelper.horizontalStrut(5), _local9);
                    this.m_statsPanel.append(_local10);
                };
                if (this.m_stats["goods"]){
                    _local11 = (new EmbeddedArt.mkt_goodsIcon() as DisplayObject);
                    _local12 = new JLabel(ZLoc.t("Dialogs", "NumGoods", {num:this.m_stats["goods"]}));
                    _local12.setFont(ASwingHelper.getBoldFont(12));
                    _local12.setForeground(_local2);
                    _local13 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local13.appendAll(new AssetPane(_local11), ASwingHelper.horizontalStrut(5), _local12);
                    this.m_statsPanel.append(_local13);
                };
                if (this.m_stats["premium_goods"]){
                    _local14 = (new EmbeddedArt.mkt_premiumGoodsIcon() as DisplayObject);
                    _local15 = new JLabel(ZLoc.t("Dialogs", "NumPremiumGoods", {num:this.m_stats["premium_goods"]}));
                    _local15.setFont(ASwingHelper.getBoldFont(12));
                    _local15.setForeground(_local2);
                    _local16 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local16.appendAll(new AssetPane(_local14), ASwingHelper.horizontalStrut(5), _local15);
                    this.m_statsPanel.append(_local16);
                };
                if (this.m_stats["energy"]){
                    _local17 = (new EmbeddedArt.mkt_energyIcon() as DisplayObject);
                    _local18 = new JLabel(ZLoc.t("Dialogs", "NumEnergy", {num:this.m_stats["energy"]}));
                    _local18.setFont(ASwingHelper.getBoldFont(12));
                    _local18.setForeground(_local2);
                    _local19 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                    _local19.appendAll(new AssetPane(_local17), ASwingHelper.horizontalStrut(5), _local18);
                    this.m_statsPanel.append(_local19);
                };
            };
            if (this.m_stats["population"]){
                _local20 = new JLabel(ZLoc.t("Dialogs", "TT_Allows"));
                _local20.setFont(ASwingHelper.getBoldFont(11));
                _local20.setForeground(_local1);
                _local21 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                _local21.append(_local20);
                _local22 = (new EmbeddedArt.mkt_populationIcon() as DisplayObject);
                _local23 = new JLabel(ZLoc.t("Dialogs", "TT_ExpansionPopulationReq", {population:this.m_stats["population"]}));
                _local23.setFont(ASwingHelper.getBoldFont(12));
                _local23.setForeground(_local2);
                _local24 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                _local24.appendAll(new AssetPane(_local22), ASwingHelper.horizontalStrut(5), _local23);
                this.m_statsPanel.appendAll(_local21, _local24);
            };
            if (((!((this.m_stats["bonus"] == null))) && ((this.m_stats["bonus"].length > 0)))){
                _local25 = new JLabel(ZLoc.t("Dialogs", "TT_Bonus"));
                _local25.setFont(ASwingHelper.getBoldFont(11));
                _local25.setForeground(_local1);
                _local26 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                _local26.append(_local25);
                this.m_statsPanel.append(_local26);
                for each (_local27 in this.m_stats["bonus"]) {
                    _local28 = ASwingHelper.makeMultilineText(ZLoc.t("Items", _local27), 190, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 12, EmbeddedArt.greenTextColor);
                    this.m_statsPanel.append(_local28);
                };
            };
            this.m_statsPanel.setPreferredHeight(BOX_HEIGHT);
            this.m_statsPanel.setMinimumHeight(BOX_HEIGHT);
            this.m_statsPanel.setMaximumHeight(BOX_HEIGHT);
            this.append(this.m_statsPanel);
        }
        protected function onPicLoad(_arg1:Event):void{
            if (this.m_pictureLoader){
                this.m_picture = this.m_pictureLoader;
            };
            if ((this.m_picture is Bitmap)){
                (this.m_picture as Bitmap).smoothing = true;
            };
            this.placePicture();
        }
        protected function placePicture():void{
            var _local1:Sprite = new Sprite();
            _local1.addChild(this.m_picture);
            this.m_picturePanel.addChild(_local1);
            _local1.x = ((this.m_picturePanel.width / 2) - (this.m_picture.width / 2));
            _local1.y = ((this.m_picturePanel.height / 2) - (this.m_picture.height / 2));
            ASwingHelper.prepare(this);
        }

    }
}//package Display.UpgradesUI 
